"""
@author: jiangpj
@email: pj.jiang@hzgosun.com
@file: userViewListPage.py
@time: 2019/5/22 11:32

前台用户管理的增删改查自动化测试用例编写

"""
from src.common.poium import Page
from src.common.vue.button import VueButton
from src.common.vue.float_window import FloatWindow
from src.common.vue.label import ElementType as ET
from src.common.vue.label import ElementBaseLabel
from src.common.vue.region import VueRegion
from src.common.vue.search import VueSearch
from src.common.vue.table import VueTable, VueTurnPage
from src.common.vue.tree import VueTree


class SearchTools(VueSearch):
    """查询区域"""

    number = ElementBaseLabel(ET.INPUT, label="账号名称")
    search_btn = VueButton("检索")   # 查询按钮

    def __init__(self):
        super(SearchTools, self).__init__()


class Table(VueTable):
    """人口表"""

    add_btn = VueButton("新建")

    def __init__(self):
        super(Table, self).__init__()


class AddPersonWindow(FloatWindow):
    """添加人口信息弹窗"""
    idname = ElementBaseLabel(ET.INPUT, label="账号名称")
    gen = ElementBaseLabel(ET.DROPDOWN_LIST, label="账号类别")
    id_ = ElementBaseLabel(ET.DROPDOWN_LIST, label="权限级别")
    region = ElementBaseLabel(ET.REGION, label="区域")
    # 这里region_selector会有bug，如果查询区域展开了1个以上，不刷新网页前提下，这里的index不能确定，需要加个visiable的判断
    # 另外，添加人口这里区域选择器是4级的，但一般用3级，默认level就行
    region_selector = VueRegion(index=0)   # , region_level=3
    jue = ElementBaseLabel(ET.DROPDOWN_LIST, label="角色")
    grid = ElementBaseLabel(ET.GRID, label="网格")
    grid_selector = VueTree(index=0)
    duty = ElementBaseLabel(ET.DROPDOWN_LIST, label="职务")
    name = ElementBaseLabel(ET.INPUT, label="姓名")
    phone = ElementBaseLabel(ET.INPUT, label="联系方式")
    state = ElementBaseLabel(ET.DROPDOWN_LIST, label="状态")

    def __init__(self, title=None, index=None):
        super(AddPersonWindow, self).__init__(title=title, index=index)


class ModiyPersonWindow(AddPersonWindow):
    """修改人口信息弹窗"""

    def __init__(self, title=None, index=None):
        super(ModiyPersonWindow, self).__init__(title=title, index=index)


class RmPersonWindow(AddPersonWindow):
    """修改人口信息弹窗"""

    def __init__(self, title=None, index=None):
        super(RmPersonWindow, self).__init__(title=title, index=index)


class UserViewList(Page):
    searchTools = SearchTools()      # 查询区域
    table = Table()  # 列表
    turnPage = VueTurnPage()  # 翻页
    addPerson = AddPersonWindow(index=1)
    modifyPerson = ModiyPersonWindow(title='账号详情')  # 修改人口弹窗
    rmPerson = RmPersonWindow(title="删除确认")